import {createRouter,createWebHashHistory} from 'vue-router';
import { navData } from '@/untils/nav';
//2. 定义一些路由
// 每个路由都需要映射到一个组件
const routes = [
    // {path:'/',name:'home',component:Home},
    // {id: 0, name: 'home', title: '首页', path: '/', component: "@/componets/Counter.vue"},
    // {id: 0, name: 'home', title: '首页X', path: '/', component: "@/componets/CounterX.vue"},
    // {id: 1, name: 'Event', title: '组件通信', path: '/', component: "@/componets/event/index.vue"},
    // {id: 1, name: 'Report', title: '学生成绩单', path: '/', component: "@/componets/Report.vue"},
    // {id: 1, name: 'HelloWorld', title: 'HelloWorld', path: '/', component: "@/componets/HelloWorld.vue"},
    // {id: 1, name: 'Loading', title: '加载中', path: '/', component: "@/componets/Loading.vue"},
    // {id: 1, name: 'LoadingX', title: 加载中X, path: '/', component: "@/componets/LoadingX.vue"},
    // {id: 1, name: 'Student', title: '学生信息', path: '/', component: "@/componets/Student.vue"},
    // {id: 1, name: 'LoginVerify', title: '用户名翻转', path: '/', component: "@/componets/LoginVerify.vue"},
    // {id: 1, name: 'Reverse', title: '字符串翻转', path: '/', component: "@/componets/Reverse.vue"},
]

navData.forEach((element)=>{
    routes.push({
        id:element.id,
        name:element.name,
        title:element.title,
        path:element.path,
        component:()=>import("@/"+element.component)
    })
})
// 3.创建路由实力并传递‘routes’配置
const router = createRouter({
    // 4. 内部提供了history模式的实现
    history: createWebHashHistory(),
    routes,// ‘router：rotues’的缩写
})
export default router